import { defHttp } from '@/utils/http/axios';
import { RoleProcessPerm, RoleProcessPermQuery, RoleProcessPermPageResult } from '@/model/workflow/roleProcessPerm.model';

const baseUrl = '/workflow/roleProcessPerm';

export function getRoleProcessPermList(params: RoleProcessPermQuery) {
  return defHttp.get<RoleProcessPermPageResult>({ url: `${baseUrl}/list`, params });
}

export function getRoleProcessPermInfo(id: number) {
  return defHttp.get<RoleProcessPerm>({ url: `${baseUrl}/${id}` });
}

export function addRoleProcessPerm(data: RoleProcessPerm) {
  return defHttp.post({ url: baseUrl, data });
}

export function editRoleProcessPerm(data: RoleProcessPerm) {
  return defHttp.put({ url: baseUrl, data });
}

export function delRoleProcessPerm(id: number) {
  return defHttp.delete({ url: `${baseUrl}/${id}` });
}

export function batchDelRoleProcessPerm(ids: number[]) {
  return defHttp.delete({ url: `${baseUrl}/batch/${ids.join(',')}` });
}

// 批量分配
export function batchAssignRoleProcessPerm(data: { roleId: number; processKeys: string[] }) {
  return defHttp.post({ url: `${baseUrl}/batchAssign`, data });
}

// 批量解绑
export function batchUnbindRoleProcessPerm(data: { roleId: number; processKeys: string[] }) {
  return defHttp.post({ url: `${baseUrl}/batchUnbind`, data });
} 